package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.pojo.item.TbItem;
import com.dongdongshop.pojo.item.TbItemExample;
import com.dongdongshop.service.item.ItemServiceI;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Service
@Component
public class ItemServiceImpl implements ItemServiceI {
    @Resource
    private TbItemMapper itemMapper;

    @Override
    public List<TbItem> selectItemList(Long id) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andGoodsIdEqualTo(id);
        criteria.andStatusEqualTo("1");
        example.setOrderByClause("is_default desc");
        return itemMapper.selectByExample(example);
    }

    @Override
    public TbItem getItemByItemId(Long itemId) {
        return itemMapper.selectByPrimaryKey(itemId);
    }

    @Override
    public List<TbItem> getItemList(Long x) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andStatusEqualTo("1");
        criteria.andGoodsIdEqualTo(x);
        example.setOrderByClause("is_default desc");
        return itemMapper.selectByExample(example);
    }
}
